package com.mvp.shq.washer.ui.aboutUs;

import com.mvp.shq.washer.entity.BasicInfo;
import com.mvp.shq.washer.entity.result.BaseResult;
import com.mvp.shq.washer.http.BaseObserver;

/**
 * Created by Administrator on 2017/8/31.
 */

public class Presenter extends AboutUsConstract.Presenter {
    @Override
    public void onStart() {

    }

    @Override
    void getAboutUs() {
        String key = "AboutUs";
        model.getAboutUs(key)
                .compose(getActivityLifecycleProvider().bindToLifecycle())
                .subscribe(new BaseObserver<BasicInfo>(view) {
                    @Override
                    protected void onSuccees(BaseResult<BasicInfo> t) throws Exception {
                        if (t.isError()){
                            view.getAboutUsF(t.getMsg());
                        }else {
                            view.getAboutUsS(t.getData().getMsgContent());
                        }
                    }

                    @Override
                    protected void onFailure(Throwable e, boolean isNetWorkError) throws Exception {
                        e.printStackTrace();
                        view.getAboutUsF("未知错误");
                    }
                });
    }
}
